{extend name="public:base" /}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__INDEX__/css/public.css">
<link rel="stylesheet" type="text/css" href="__INDEX__/css/style.css">
<link rel="stylesheet" type="text/css" href="__INDEX__/css/responsive.css">
<link rel="shortcut icon" href="__INDEX__/images/favorite.ico">
{/block}
{block name="html"}
<form>
<div class="main" id="submitOrder-box">
    <h3>确认订单信息</h3>
    <div class="checkOrder-info">
        <div class="checkOrder-th">
            <p class="proName-th">商品</p>
            <p class="singlePrice-th">单价</p>
            <p class="Num-th">数量</p>
            <p class="youhui-th">优惠</p>
            <p class="singleTotal-th">小计</p>
        </div>
        <ul>
            <li>
                <a href="pro_detail.html">
                    <div class="pro">
                        <img src="{$data['images']}">
                        <div class="l">
                            <p class="proName">{$data['name']}</p>
                        </div>
                    </div>
                    <p class="price">￥{$data['price']}</p>
                    <p class="num">{$data['buy_num']}</p>
                    <!-- <p class="youhui">￥{$data['price']}</p> -->
                </a>
            </li>
        </ul>
    </div>
    <div><a href="#">买家留言：<input placeholder="填写卖家需求" type="text" id="remark" name="remark"/></a></div>
    <div class="agin_submit">
        <div class="agin_submit_info">
            <p>实付款：<span class="price">￥{$data.buy_num*$data.price}</span></p>
        </div>
    </div>
    <p class="submit-p">
        <a href='javascript:;' class="submit payBtn">提交订单</a>

        <input type="hidden" name="goods_id" id="goods_id" value="{$data.id}"/>
        <input type="hidden" name="goods_name" id="name" value="{$data.name}"/>
        <input type="hidden" name="goods_images" id="images" value="{$data.images}"/>
        <input type="hidden" name="goods_price" id="price" value="{$data.price}"/>
        <input type="hidden" name="buy_num" id="buy_sum" value="{$data.buy_num}"/>
        <input type="hidden" name="pay_type" id="pay_type" value="WeChat">
    </p>
</div>
</form>
{/block}

{block name="javascript"}
<script src="__INDEX__/js/jquery-1.9.1.min.js"></script>
<script src="__INDEX__/js/public.js"></script>
<script src="__INDEX__/layer/layer.js"></script>
<script src="__INDEX__/js/jquery.imagezoom.min.js"></script>
<script src="__INDEX__/js/common.js"></script>

<script>

    $(".payBtn").click(function(){
        layer.confirm('您是如何看待前端开发？', {
            content: '请选择支付方式',
            btn: ['线下支付','微信支付','支付宝'], //按钮
        }, function(){
            $("#pay_type").val("xianx");
            submitPay();
        }, function(){
            $("#pay_type").val("WeChat");
            submitPay();
        }, function(){
            $("#pay_type").val("Alipay");
            submitPay();
        });
    })
    
    function submitPay(){
        var goods_id = $("#goods_id").val();
        var price = $("#price").val();
        var buy_sum = $("#buy_sum").val();
        var remark = $("#remark").val();
        if( goods_id == "" || buy_sum == "" ){
            prompt_From_one("你的订单数据有误");
            return false;
        }
        var post_data = $("form").serialize();
        $.ajax({
            type: 'POST',
            url: '{:url("Order/pay")}',
            dataType: 'json',
            data: post_data,
            success: function (data) {
                if( data.id == 0 ){
                    var url = data.content;
                    location.href = url.url;
                }else{
                    prompt_From_one(data.msg);
                }
            }
        });
    }
</script>
{/block}
